<%= content_tag :div,
  class: class_names(
    "avo-sidebar fixed z-[60] t-0 application-sidebar w-64 flex-1 border-r lg:border-none bg-none xh-dvh h-[calc(100dvh-4rem)] bg-application lg:bg-transparent",
    "print:hidden": Avo.configuration.hide_layout_when_printing,
    "hidden": !@sidebar_open,
  ),
  data: {
    sidebar_target: stimulus_target
  } do %>
  <div class="flex flex-col w-full h-full">
    <div class="flex-1 flex flex-col justify-between overflow-auto h-full pt-3 mac-styled-scrollbar">
      <div class="space-y-6 mb-4">
        <%= render Avo::Sidebar::LinkComponent.new label: 'Get started', path: helpers.avo.root_path, active: :exclusive if Rails.env.development? && Avo.configuration.home_path.nil? %>

        <% if Avo.plugin_manager.installed?("avo-menu") && Avo.has_main_menu? %>
          <% Avo.main_menu.items.each do |item| %>
            <%= render Avo::Sidebar::ItemSwitcherComponent.new item: item %>
          <% end %>
        <% else %>

          <% if dashboards.present? %>
            <div>
              <%= render Avo::Sidebar::HeadingComponent.new label: t('avo.dashboards'), icon: helpers.svg("avo/dashboards", class: 'h-4') %>

              <div class="w-full space-y-1">
                <% dashboards.sort_by { |r| r.navigation_label }.each do |dashboard| %>
                  <%= render Avo::Sidebar::LinkComponent.new label: dashboard.navigation_label, path: helpers.avo_dashboards.dashboard_path(dashboard) %>
                <% end %>
              </div>
            </div>
          <% end %>

          <div>
            <%= render Avo::Sidebar::HeadingComponent.new label: t('avo.resources'), icon: helpers.svg("avo/resources", class: 'h-4') %>

            <div class="w-full space-y-1">
              <% resources.sort_by { |r| r.navigation_label }.each do |resource| %>
                <%= render Avo::Sidebar::LinkComponent.new label: resource.navigation_label, path: helpers.resources_path(resource: resource) %>
              <% end %>
            </div>
          </div>

          <% if tools.present? %>
            <div>
              <%= render Avo::Sidebar::HeadingComponent.new label: t('avo.tools'), icon: helpers.svg("avo/tools", class: 'h-4') %>

              <div class="w-full space-y-1">
                <% tools.each do |partial| %>
                  <%= render partial: "/avo/sidebar/items/#{partial}" %>
                <% end %>
              </div>
            </div>
          <% end %>

          <% if Avo::MediaLibrary.configuration.visible? %>
            <%= render Avo::Sidebar::LinkComponent.new label: 'Media Library', path: helpers.avo.media_library_index_path, active: :exclusive %>
          <% end %>
        <% end %>

        <%= render partial: "/avo/partials/sidebar_extra" %>
      </div>
    </div>
    <% if Rails.env.development? %>
      <div class="p-4 border-t group">
        <%= link_to helpers.avo.avo_private_status_path, class: "block px-4 py-2 border rounded flex justify-between items-center w-full text-black text-sm" do %>
          <span>Avo Status</span> <span><div class="rounded-full w-4 h-4 <%= Avo.app_status ? "bg-green-400" : "bg-orange-400" %>"></div></span>
        <% end %>
        <div class="absolute text-xs text-gray-700 group-hover:block hidden text-center w-full -ml-4">👆Visible only in development👆</div>
      </div>
    <% end %>
    <%= render Avo::SidebarProfileComponent.new user: helpers._current_user %>
  </div>
<% end %>
